<!DOCTYPE HTML>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>车型品牌</title>
    <link rel="stylesheet" type="text/css" href="css/v2/base.css" />
    <link rel="stylesheet" type="text/css" href="css/v2/car_release.css" />
   	<style>

   	</style>
</head>
<body style="background:#fff;overflow:">
	<div class="car-brand" id="app" v-cloak>
		<div v-show="showCity===false" class="province-w">
			<dl v-for="item in provinceList">
				<dt :id="item[0].namepy">{{item[0].namepy}}</dt>
				<dd @click="selCity(itemM.id,itemM.name);" v-for="itemM in item" tapmode>{{itemM.name}}</dd>
			</dl>
			<ul class="left-bar flex-center" style="display: none;"><!--快速跳转，暂时先隐藏-->
				<li v-for="item in provinceList" :class="{on:selectIndex==item[0].namepy}"><a @click.stop="selectIndex=item[0].namepy" v-bind:href="'#'+item[0].namepy" tapmode>{{item[0].namepy}}</a></li>
			</ul>
		</div>
		<!--以上省份-->
		<div v-show="showCity===true" class="city-w">
			<dl v-for="item in cityList">
				<dd @click="determine(item.name,item.id,'showRegion')" tapmode>{{item.name}}</dd>
			</dl>
		</div>
		<!--以上城市-->
		<div v-show="showRegionM" class="city-w">
			<dl v-for="item in regionList">
				<dd @click="selRegion(item.name,item.id)" tapmode>{{item.name}}</dd>
			</dl>
		</div>
		<!--以上地区-->
	</div>	
</body>
<script type="text/javascript" src="vue.min.js"></script>



<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="api.js"></script>
<script>
    function testMethod () {
        alert($)
        var url ='http://www.cherongdao.com/mobile/gateway/' + 1002;
        $.ajax({
               url : url,
               data : {},
               type : 'post',
               dataType : 'json',
               success : function(ret) {
               alert("成功")
               },error:function(XMLHttpRequest, textStatus, errorThrown){
               alert(JSON.stringify(XMLHttpRequest))
               }
               })
               return true;
    }
</script>
<script type="text/javascript">
    
    alert(1)
    return false;
	var address;
	var url ='http://192.168.3.155:28080/jeesite/mobile/gateway/' + 1002;
	$.ajax({
		url : url,
		data : {},
		type : 'post',
		dataType : 'json',
		success : function(ret) {
			alert(成功)
		}
	})
	
	var vm=new Vue({
		el:'#app',
		data:{
			showCity:false,
			areaList:[],
			cityList:[],
			provinceList:[],
			regionList:[],
			selectIndex:'',
			addressName:'',
			showRegion:false,
			showRegionM:false
		},
		methods:{
			selCity:function(id,name){
				vm.addressName=name;
				vm.cityList=[];
				vm.showCity=true;
				for(var i=0;i<address.rows.length;i++){
					if(address.rows[i].parentId==id && address.rows[i].type==2){
						vm.cityList.push(address.rows[i]);
					}	
				}
			},
			determine:function(name,id,type){
				vm.addressName=vm.addressName+' '+name;
				if(type=="showRegion"){
					if(!vm.showRegion){
						api.sendEvent({
			                name:'address',
			                extra: {
						        name: name,
						        id: name,
						        all:vm.addressName,
						        newId:id
						    }
		                });
		                if(api.pageParam){
		                	if(api.pageParam.toFrame){
		                		if(api.pageParam.toFrame.fromFrame){
									if(api.pageParam.toFrame.fromFrame=='home'){
										api.sendEvent({
										name:'addressHome',
										    extra: {
										        name: name,
										        id: name,
										        all:vm.addressName,
										        newId:id
										    }
										});
									};
		                		}
		                	}
		                };
		                api.closeWin();
					}
					else{
						vm.regionList=[];
						for(var i=0;i<address.rows.length;i++){
							if(address.rows[i].parentId==id && address.rows[i].type==3){
								vm.regionList.push(address.rows[i]);
							};	
						};
						if(vm.regionList.length==0){
							api.sendEvent({
				                name:'toInfo',
				                extra: {
							        name: vm.addressName,
							        id: id
							    }
			                });
			                api.closeWin();
						}else{
							vm.showCity=null;
							vm.showRegionM=true;
						};
					}
				}
			},
			selRegion:function(name,id){
				api.sendEvent({
	                name:'toInfo',
	                extra: {
				        name: vm.addressName + ' ' +name,
				        id: id
				    }
                });
                api.closeWin();
			}
		},//methods
	})
</script>
</html>
